package com.swm.util;


import com.alibaba.fastjson2.JSONObject;
import com.swm.mapper.StockDayDataMapper;
import com.swm.mapper.StockMapper;
import com.swm.pojo.Stock;
import com.swm.pojo.Stock_Day_Data;
import org.apache.ibatis.session.SqlSession;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author 师文明
 * @data 2024/12/23 下午3:11
 **/
public class getStockDayData464 {
    static SqlSession sqlSession = SqlSessionUtil.openSession();
    static StockDayDataMapper stockDayDataMapper = sqlSession.getMapper(StockDayDataMapper.class);
    static StockMapper mapper = sqlSession.getMapper(StockMapper.class);
   static SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd hh:mm:ss:sss");
 /*   public static void main(String[] args) throws Exception {
        System.out.println(sdf.format(new Date()));
        List<Stock_Day_Data> stockDayData1 = stockDayDataMapper.selectAllStockDayData();

        System.out.println(stockDayData1.size());
        System.out.println(sdf.format(new Date()));
        List<Stock> stcokList = getStcokList();
        stcokList.forEach(stock -> {
            List<Stock_Day_Data> stockDayData = new ArrayList<Stock_Day_Data>();
            stockDayData1.forEach(stockDayData2 -> {
                if(stockDayData2.getCode().equals(stock.getCode())){
                    stockDayData.add(stockDayData2);

                }

            });
            //System.out.println(stockDayData.size());
            //System.out.println(sdf.format(new Date()));
        });
        System.out.println(sdf.format(new Date()));
        System.out.println(215);
    }*/
 public static void main(String[] args) {
     System.out.println(sdf.format(new Date()));
     List<Stock_Day_Data> stockDayData1 = stockDayDataMapper.selectAllStockDayData();

     System.out.println(stockDayData1.size());
     System.out.println(sdf.format(new Date()));
     List<Stock> stcokList = getStcokList();
     stcokList.forEach(stock -> {
         List<Stock_Day_Data> stockDayData = new ArrayList<Stock_Day_Data>();
         stockDayData1.forEach(stockDayData2 -> {
             if(stockDayData2.getCode().equals(stock.getCode())){
                 stockDayData.add(stockDayData2);

             }

         });
         //System.out.println(stockDayData.size());
         //System.out.println(sdf.format(new Date()));
     });
     System.out.println(sdf.format(new Date()));
     System.out.println(215);
 }

    public static List<Stock> getStcokList() {
        List<Stock> stocks = mapper.selectAllStock();
        JSONObject jsonObject = new JSONObject();

        for (Stock stock : stocks) {
            String code = stock.getCode();
            int type = stock.getType();
            jsonObject.put(code, type);

        }
        return stocks;
    }
}

